<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="base::head(~{})"></head>
<body>
<div class="x-body layui-anim layui-anim-up">
  <fieldset class="layui-elem-field layui-field-title">
    <legend>编辑</legend>
  </fieldset>
  <form id="form" class="layui-form layui-form-pane" action="">
    <input type="hidden" name="id" th:value="${systemGroup.id}">
    <div class="layui-form-item">
      <label class="layui-form-label">上级机构</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${psystemGroup.groupName}" autocomplete="off" readonly="readonly" class="layui-input">
        <input type="hidden" name="pid" th:value="${psystemGroup.id}" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">组织名称</label>
      <div class="layui-input-inline">
        <input type="text" name="groupName" th:value="${systemGroup.groupName}" placeholder="请输入..." class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <button class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
      <a href="javascript:;" id="close" class="layui-btn">关闭</a>
    </div>
  </form>
</div>
</body>
<script>
  layui.use(['form', 'laydate'], function () {
    var form = layui.form, laydate = layui.laydate;
    //监听提交
    form.on('submit(submit)', function (data) {
      $.ajax({
        type: 'post',//方法类型
        dataType: 'json',//预期服务器返回的数据类型
        url: ctxPath + '/systemGroup/update',//url
        data: $('#form').serialize(),
        success: function (result) {
          if (result.code == 0) {
            admin_close_success_msg('保存成功');
            parent.reload();
            return;
          } else {
            layer.msg('保存失败。错误信息：' + result.msg, {icon: 2});
            return;
          }
        },
        error: function () {
          layer.msg('保存失败', {icon: 2});
        }
      });
      return false;
    });
    $('#close').on('click', function () {
      admin_close_iframe_window();
    });
  });
</script>
</html>